/**
 * NutchEventDispatcher.java created at 2009-3-6
 * Copyrights Reserved. 2006
 */
package org.apache.nutch.web;

import java.util.EventListener;
import java.util.EventObject;
import java.util.concurrent.Executor;

import org.recoil.pixel.dispatchable.DispatchableEvent;
import org.recoil.pixel.dispatchable.DispatchableEventSupport;
import org.recoil.pixel.executor.DirectExecutor;

/**
 * 
 * 
 * @author yanky
 */
public class NutchEventDispatcher {

	Executor e = new DirectExecutor(); //[1]
    DispatchableEventSupport<NutchListener> d = new DispatchableEventSupport<NutchListener>(e);
    
    public void addListener(NutchListener l) {
        d.addListener(l);
    }
    
    public void removeListener(NutchListener l) {
        d.removeListener(l);
    }
    
    public void fireEvent(NutchEvent e) {
        d.fireEvent(new DispatchableEvent<NutchListener, NutchEvent>(e) {
            public void dispatch( NutchListener l, NutchEvent ce) {
                l.statusUpdate(ce); //[2]
            }	
        });            
    }
}

class NutchEvent extends EventObject {
	
	public NutchEvent(Object source) {
		super(source);
	}
}

interface NutchListener extends EventListener {
	public void statusUpdate(NutchEvent e);
}


